<%@ Import namespace="MIMS_WRS.Web" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="DOList.aspx.vb" Inherits="MIMS_WRS.Web.DOList"%>
<%@ Register TagPrefix="uc1" TagName="JSCalendarSetup" Src="../UserControls/JSCalendarSetup.ascx" %>
<%@ Register TagPrefix="uc1" TagName="DateTimePicker" Src="../UserControls/DateTimePicker.ascx" %>
<%@ Register TagPrefix="uc1" TagName="RecordNavigator" Src="../UserControls/RecordNavigator.ascx" %>
<%@ Register TagPrefix="uc1" TagName="BODetailTab" Src="../UserControls/BODetailTab.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<title>Delivered Order List</title>
		<LINK href="detail.css" type="text/css" rel="stylesheet" name="Default stylesheet">
			<LINK href="common.css" type="text/css" rel="stylesheet" name="Default stylesheet">
				<script language="javascript" src="../js/common.js"></script>
				<script language="javascript">
		function openDialog() {
			var url = '../Offices/DOAddDialog.aspx?sup=<%=RequestContext.SupplierCode%>';
			var title = escape('Add Delivered Order Dialog');
			var height = 560;
			var width = 400;
			var iTop = (screen.height-height-30)/2;
			var iLeft = (screen.width-width)-40;			
			return window.showModalDialog('../Dialogs/ShowDialog.aspx?title=' + title + '&src=' + url, '', 'dialogLeft: ' +iLeft+ 'px; dialogTop:' + iTop+ 'px; dialogHeight: ' + height + 'px; dialogWidth: ' + width + 'px; center: no; resizable: no; scroll: no; status: no;');
		}
		<!--
		function addNewDO() {
			result = openDialog();
			if (result != null) {
				var btnAddDO = window.document.getElementById('<%= btnAddDO.ClientID %>');
				var hidOfficeID = window.document.getElementById('<%= hidOfficeID.ClientID %>');
				var hidPOID = window.document.getElementById('<%= hidPOID.ClientID %>');
				var hidOrderNo = window.document.getElementById('<%= hidOrderNo.ClientID %>');
				var hidSupplierCode = window.document.getElementById('<%= hidSupplierCode.ClientID %>');
				var hidOrderDate = window.document.getElementById('<%= hidOrderDate.ClientID %>');
				var hidIssuedDate = window.document.getElementById('<%= hidIssuedDate.ClientID %>');
				var hidIssuedQty = window.document.getElementById('<%= hidIssuedQty.ClientID %>');
				var hidCustomerName = window.document.getElementById('<%= hidCustomerName.ClientID %>');
				
				hidOfficeID.value = result.OfficeID;
				hidPOID.value = result.POID;
				hidOrderNo.value = result.OrderNumber;
				hidSupplierCode.value = result.SupplierCode;
				hidOrderDate.value = result.OrderDate;
				hidIssuedDate.value = result.IssuedDate;
				hidIssuedQty.value = result.IssuedQty;
				hidCustomerName.value = result.CustomerName;
				btnAddDO.click();
			}
		}
		
		function openAQDialog() {
			var url = '../Offices/AQAddDialog.aspx';
			var title = escape('Add Adjust Quantity Dialog');
			var height = 560;
			var width = 400;
			var iTop = (screen.height-height-30)/2;
			var iLeft = (screen.width-width)-40;			
			return window.showModalDialog('../Dialogs/ShowDialog.aspx?title=' + title + '&src=' + url, '', 'dialogLeft: ' +iLeft+ 'px; dialogTop:' + iTop+ 'px; dialogHeight: ' + height + 'px; dialogWidth: ' + width + 'px; center: no; resizable: no; scroll: no; status: no;');
		}
		
		function addNewAQ() {
			result = openAQDialog();
			if (result != null) {
				var btnAddAQ = window.document.getElementById('<%= btnAddAQ.ClientID %>');
				var hidComment = window.document.getElementById('<%= hidAQComment.ClientID %>');
				var hidAmount = window.document.getElementById('<%= hidAQAmount.ClientID %>');
				var hidAQPOID = window.document.getElementById('<%= hidAQPOID.ClientID %>');
				hidComment.value = result.Comment;
				hidAmount.value = result.Amount;	
				hidAQPOID.value = result.POID;		
				btnAddAQ.click();
			}
		}
		
		function refreshOpener() {
			if (window.opener.form1.btnRefresh)
				window.opener.form1.btnRefresh.click();
		}
	
		function windowCloseAndRefresh() {
			isAlreadyRefresh = true;
			<% If RequestContext.Changed = True Then %>
				refreshOpener();
			<% End If %>
			window.close();
		}
	
		//-->
				</script>
	</HEAD>
	<body>
		<form id="Form1" method="post" runat="server">
			<uc1:RecordNavigator id="RecordNavigator1" runat="server"></uc1:RecordNavigator>
			<uc1:BODetailTab id="BODetailTab1" runat="server"></uc1:BODetailTab>
			<uc1:JSCalendarSetup id="JSCalendarSetup1" runat="server"></uc1:JSCalendarSetup>
			<fieldset>
				<legend>Delivered Orders</legend>
				<div style="CLEAR: left;PADDING-RIGHT: 5px;PADDING-LEFT: 5px;PADDING-BOTTOM: 5px;PADDING-TOP: 5px">
					<a href="javascript:;" onclick="addNewDO(); return false;">Add new delivered 
						order...</a>
				</div>
				<div style="OVERFLOW:auto; WIDTH:100%; HEIGHT:300px; BACKGROUND-COLOR:whitesmoke">
					<asp:Repeater ID="rptDO" Runat="server">
						<HeaderTemplate>
							<table class="FormTable" width="100%">
								<thead>
									<th>
										Req No</th>
									<th>
										S.Order</th>
									<th>
										Owner</th><th>Supp O/No</th><th>Order No</th><th>YY</th><th>Order Date</th><th>Shipped 
										Date</th><th>Customer Name</th><th>Qty Issued. Units</th><th>Date Issued</th><th width="5%">Action</th>
								</thead>
								<tbody>
						</HeaderTemplate>
						<ItemTemplate>
							<tr>
								<td><%# Convert.ToString(DataBinder.Eval(Container.DataItem, "REQ")).PadLeft(4, "0"c)%></td>
								<td><%# Utilities.GetNormalText(DataBinder.Eval(Container.DataItem, "SalesOrder")).PadLeft(5, "0"c)%></td>
								<td><input type=hidden runat=server id=hidDOId value='<%# DataBinder.Eval(Container.DataItem, "DeliveredOrderID") %>'><%# DataBinder.Eval(Container.DataItem, "OfficeName") %></td>
								<td><%# Convert.ToString(DataBinder.Eval(Container.DataItem, "SupplierCode")).PadLeft(3, "0"c) %></td>
								<td><%# Convert.ToString(DataBinder.Eval(Container.DataItem, "OrderNo")).PadLeft(3, "0"c) %></td>
								<td><%# DataBinder.Eval(Container.DataItem, "YY") %></td>
								<td><%# Ctype(DataBinder.Eval(Container.DataItem, "OrderDate"), DateTime).ToShortDateString() %></td>
								<td><%# Ctype(DataBinder.Eval(Container.DataItem, "ShippedDate"), DateTime).ToShortDateString() %></td>
								<td><%# DataBinder.Eval(Container.DataItem, "CustomerName") %></td>
								<td>
									<asp:TextBox onkeypress="NumberOnly(0)" MaxLength=5 text='<%# DataBinder.Eval(Container.DataItem, "QtyIssued") %>' Columns="8" ID="txtQtyIssued" Runat="server">
									</asp:TextBox>
									<asp:RequiredFieldValidator ControlToValidate="txtQtyIssued" Runat="server" ID="rqvQtyIssued" ErrorMessage="please input issued quantity">!</asp:RequiredFieldValidator></td>
								<td>
									<uc1:DateTimePicker id="calDateIssued" runat="server" EnableRequiredValidator="true" RequiredErrorMessage="please input order date"
										RequiredText="!"></uc1:DateTimePicker></td>
								<td>
									<asp:LinkButton ID="lnkDelete" Runat="server" CommandName="delete">delete</asp:LinkButton></td>
							</tr>
						</ItemTemplate>
						<FooterTemplate>
							</tbody></table>
						</FooterTemplate>
					</asp:Repeater>
				</div>
			</fieldset>
			<fieldset>
				<legend>Adjusted Quantities</legend>
				<div style="CLEAR: left;PADDING-RIGHT: 5px;PADDING-LEFT: 5px;PADDING-BOTTOM: 5px;PADDING-TOP: 5px">
					<a href="javascript:;" onclick="addNewAQ(); return false;">Add new adjusted 
						quantity</a>
				</div>
				<div style="OVERFLOW:auto; WIDTH:100%; HEIGHT:250px; BACKGROUND-COLOR:lightyellow">
					<asp:Repeater ID="rptAQ" Runat="server">
						<HeaderTemplate>
							<table class="FormTable" width="100%" cellpadding="2" cellspacing="0">
								<thead>
									<th width="15%" align="left">
										Adjusted Date</th>
									<th width="10%" align="left" style="background-color:lightblue">
										Quantity</th>
									<th align="left">
										Comment</th>
								</thead>
								<tbody>
						</HeaderTemplate>
						<ItemTemplate>
							<tr>
								<td><%# Utilities.GetDateText(DataBinder.Eval(Container.DataItem, "AdjustedDate"))%></td>
								<td align="right" style="background-color:lightblue"><%# Utilities.GetNormalText(DataBinder.Eval(Container.DataItem, "Amount"))%></td>
								<td><%# Utilities.GetNormalText(DataBinder.Eval(Container.DataItem, "Comment"))%></td>
							</tr>
						</ItemTemplate>
						<FooterTemplate>
							</tbody></table>
						</FooterTemplate>
					</asp:Repeater>
				</div>
			</fieldset>
			<div align="center" style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; PADDING-TOP: 10px">
				<asp:Button cssclass="Button L2" Runat="server" ID="btnSaveAndNext" Text="Save &amp; Next"></asp:Button>&nbsp;<asp:Button Runat="server" ID="btnSave" Text="Save" cssclass="Button L2"></asp:Button>&nbsp;<INPUT class="Button L2" onclick="windowCloseAndRefresh();" type="button" value="Cancel">
			</div>
			<input type="button" runat="server" style="DISPLAY:none; VISIBILITY:hidden" id="btnAddDO">
			<input type="button" runat="server" style="DISPLAY:none; VISIBILITY:hidden" id="btnAddAQ">
			<input type="hidden" runat="server" id="hidOfficeID"> <input type="hidden" runat="server" id="hidPOID">
			<input type="hidden" runat="server" id="hidOrderNo"> <input type="hidden" runat="server" id="hidSupplierCode">
			<input type="hidden" runat="server" id="hidOrderDate"> <input type="hidden" runat="server" id="hidIssuedDate">
			<input type="hidden" runat="server" id="hidIssuedQty"> <input type="hidden" runat="server" id="hidCustomerName">
			<input type="hidden" runat="server" id="hidAQComment"><input type="hidden" runat="server" id="hidAQAmount">
			<input type="hidden" runat="server" id="hidAQPOID">
			<asp:ValidationSummary id="ValidationSummary1" runat="server" ShowMessageBox="True" ShowSummary="False"></asp:ValidationSummary>
		</form>
	</body>
</HTML>
